package ch.drshit.model.picture;

import java.awt.Color;
import java.util.HashMap;

import ch.drshit.model.filter.BaseFilter;
import ch.drshit.view.swing.MyOptionChooser;

public class Options implements MyOptionChooser.MyOptionChooserCloseListener {

	private boolean hasOptions;
	private HashMap<String, Byte> percentOptions;
	private HashMap<String, Color> colorOptions;
	private HashMap<String, Integer> intOptions;
	private MyOptionChooser optionChooser;
	private BaseFilter f;

	public Options() {
		this.setHasOptions(false);
		percentOptions = new HashMap<String, Byte>();
		colorOptions = new HashMap<String, Color>();
		intOptions = new HashMap<String, Integer>();
	}

	public boolean getHasOptions() {
		return hasOptions;
	}

	public boolean hasOptions() {
		return hasOptions;
	}

	public void setHasOptions(boolean hasOptions) {
		this.hasOptions = hasOptions;
	}

	public void addPercentOption(String name) {
		addPercentOption(name, (byte) 0);
	}

	public void addPercentOption(String name, byte defaultvalue) {
		percentOptions.put(name, new Byte(defaultvalue));
		this.setHasOptions(true);
	}

	public HashMap<String, Byte> getPercentOptions() {
		return this.percentOptions;
	}

	public void addColorOption(String name) {
		colorOptions.put(name, new Color(0));
		this.setHasOptions(true);
	}

	public HashMap<String, Color> getColorOptions() {
		return this.colorOptions;
	}

	public void addIntOption(String name) {
		intOptions.put(name, 0);
		this.setHasOptions(true);
	}

	public HashMap<String, Integer> getIntOptions() {
		return this.intOptions;
	}

	public void useOptions(BaseFilter f) {
		this.f = f;
		this.optionChooser = new MyOptionChooser(this, this);
	}

	@Override
	public void finish(Options o) {
		this.optionChooser.closeFrame();
		f.startFilter(o);
	}
}
